package formBean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

import util.Util;

public class BuyFundForm extends FormBean {

	private String amount;
	private String balance;
	private String fundList;

    

	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}

	public String getBalance() {
		return balance;
	}

	public void setBalance(String balance) {
		this.balance = balance;
	}

	public String getFundList() {
		return fundList;
	}

	public void setFundList(String fundList) {
		this.fundList = fundList;
	}

	public List<String> getValidationErrors() {
        List<String> errors = new ArrayList<String>();

        if(!Util.isValidMoneyAmount(amount)) errors.add("Please enter correct amount");
        if(!Util.isValidBalAmount(balance)) errors.add("Please enter correct balance");
        if(errors.size() == 0)
        {
        	System.out.println("AMOUNT" + amount);
        	if (Double.parseDouble(amount) <= 0) errors.add("Please enter correct amount");
        	if (Double.parseDouble(balance)<=Double.parseDouble(amount)) errors.add("You dont have sufficient balance to buy Funds");
        	if (fundList == null || fundList.length() == 0) errors.add("Please select some funds.");
        }
        if (errors.size() > 0) return errors;

        //if (!button.equals("Login") && !button.equals("Register") && !button.equals("Complete Registration")) errors.add("Invalid button");
        //if (email.matches(".*[<>\"].*")) errors.add("User Name may not contain angle brackets or quotes");
		
        return errors;
    }
}
